package cn.lzd.mr.case4;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Created by lzd on 2018/6/1.
 */
public class Case4Bean implements WritableComparable<Case4Bean> {

    private String orderid;
    private String code;
    private String name;
    private float money;
    private int num;

    public Case4Bean() {
    }

    public Case4Bean(String orderid, String code, String name, float money, int num) {
        this.orderid = orderid;
        this.code = code;
        this.name = name;
        this.money = money;
        this.num = num;
    }

    public void setOrderid(String orderid) {
        this.orderid = orderid;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setMoney(float money) {
        this.money = money;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getOrderid() {
        return orderid;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public float getMoney() {
        return money;
    }

    public int getNum() {
        return num;
    }

    @Override
    public int compareTo(Case4Bean o) {
        return Float.compare(this.getMoney(), o.getMoney());
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(this.orderid);
        dataOutput.writeUTF(this.code);
        dataOutput.writeUTF(this.name);
        dataOutput.writeFloat(this.money);
        dataOutput.writeInt(this.num);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.orderid = dataInput.readUTF();
        this.code = dataInput.readUTF();
        this.name = dataInput.readUTF();
        this.money = dataInput.readFloat();
        this.num = dataInput.readInt();
    }


    @Override
    public String toString() {
        return "Case4Bean{" +
                "orderid='" + orderid + '\'' +
                ", code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", money=" + money +
                ", num=" + num +
                '}';
    }
}
